package ${controllerPackage};

import ${viewPackage}.${clazz.className}${viewSuffix};
import ${servicePackage}.I${clazz.className}Service;

import jp.co.binal.framework.mvc.BaseController;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;

/**
 * Comment:  ${clazz.classComment} controller
 * @author: ${author}
 * @date: ${date}
 */
@RestController
@RequestMapping("/${clazz.supportName}")
public class ${clazz.className}Controller extends BaseController {

    /**
     * log
     */
    private static final Logger logger = LoggerFactory.getLogger(${clazz.className}Controller.class);

    /**
     * mapper
     */
    @Resource
    private I${clazz.className}Service service;

    /**
     * save
     *
     * @param vo
     * @param bindingResult
     * @return
     */
    @PostMapping("/save")
    public Result save(@Validated AttentionVO vo, BindingResult bindingResult) {
        service.save(vo);
        return Result.SUCCESS();
    }

    /**
     * delete by id
     *
     * @param id
     * @return
     */
    @PostMapping("/del")
    public Result deleteById(String id) {
        service.deleteById(id);
        return Result.SUCCESS();
    }

    /**
     * update by id
     *
     * @param vo
     * @param bindingResult
     * @return
     */
    @PostMapping("/update")
    public Result update(@Validated AttentionVO vo, BindingResult bindingResult) {
        service.updateById(vo);
        return Result.SUCCESS();
    }

    /**
     * all list
     *
     * @param id
     * @return
     */
    @GetMapping("/list")
    public Result<List<${clazz.className}${viewSuffix}>> list(String id) {
        return Result.success(service.queryAll());
    }

    /**
     * get by id
     *
     * @param id
     * @return
     */
    @GetMapping("/get")
    public Result<${clazz.className}${viewSuffix}> getById(String id) {
        return Result.success(service.queryById(id));
    }

    /**
     * pagination query
     *
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/page")
    public Result<List<${clazz.className}${viewSuffix}>> getPage(int pageNum, int pageSize) {
        return Result.success(service.queryPage(pageNum, pageSize));
    }

}